package cn.dubito.springcloud.controller;

import cn.dubito.springcloud.entity.Dept;
import cn.dubito.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liliang
 * @description:
 * @date 2018/5/20.
 */
@RestController
public class DeptControllerConsumer {

    @Autowired
    private DeptClientService service;

    /**
     * 添加
     *
     * @param dept
     * @return
     */
    @GetMapping("/consumer/dept/add")
    public boolean add(Dept dept) {
        return service.add(dept);
    }

    /**
     * 查找
     *
     * @param deptNo
     * @return
     */
    @GetMapping("/consumer/dept/{deptNo}")
    public Dept get(@PathVariable("deptNo") Long deptNo) {
        return service.get(deptNo);
    }

    /**
     * 查找全部
     *
     * @return
     */
    @GetMapping("/consumer/dept/list")
    public List<Dept> list() {
        return service.list();
    }
}
